#!/bin/ksh
#
# SpecialRdist -- specially rdist lsof 4.x sources to a specified destination
#
# Usage: GenericRdist <destination> <dialect> <shell>
#
#	 <destination>	destination host
#
#	 <dialect>	dialect subdirectory name
#
#	 <shell>	remote shell -- rsh or ssh

# Process arguments.

if test $# -ne 3
then
  echo "Usage: <destination> <dialect> <shell>"
  exit
fi
H=$1
D=$2
S=$3

# Test the shell and define it's full path, as required.

if test "X$S" = "Xrsh"
then
  SHP=""
else
  if test "X$S" = "Xssh"
  then
    SHP="-P /opt/openssh/bin/ssh"
  else
    echo "$S is not an acceptable shell; specify rsh or ssh."
    exit
  fi
fi

# Define the distfile and make sure it's removed on premature exit.

R=/tmp/distfile.$$
trap 'rm $R; exit 1' 1 2 3 15

rm -f $R
echo ". -> $H" > $R
echo "	except ( ./.ck00MAN );" >> $R
echo "	except ( ./.neverCust ./.neverInv );" >> $R
echo "	except ( ./Makefile ./ddev.c ./dfile.c ./dlsof.h ./dmnt.c );" >> $R
echo "	except ( ./dnode.c ./dnode1.c ./dproc.c ./dproto.h ./dsock.c );" >> $R
echo "	except ( ./dstore.c ./lib/Makefile ./lib/RCS ./lib/OLD ./lib/NEW );" >> $R
echo "	except ( ./lsof ./machine.h ./version.h ./zipme );" >> $R
echo "	except ( ./NEW ./OLD ./RCS ./dialects ./support ) ;" >> $R
echo "	except ( ./new ./old ./X ./xxx ./errs ) ;" >> $R
echo "	except ( ./scripts/OLD ./scripts/NEW ./scripts/RCS ) ;" >> $R
echo "	except ( ./scripts/00MANIFEST ./scripts/00README ) ;" >> $R
echo "	except ( ./tests/OLD ./tests/NEW ./tests/RCS ) ;" >> $R
echo "	except ( ./tests/00README ) ;" >> $R
echo "	except ( ./tests/LTbasic ./tests/LTbigf ./tests/LTdnlc ) ;" >> $R
echo "	except ( ./tests/LTlock ./tests/LTnfs ./tests/LTnlink ) ;" >> $R
echo "	except ( ./tests/LTsock ./tests/LTszoff ./tests/LTunix ) ;" >> $R
echo "	except_pat ( \\\\./tests/config\\\\. );" >> $R
echo "	except_pat ( \\\\.gz \\\\.o \\\\.a );" >> $R
echo "	install src/lsof4 ;" >> $R
echo "" >> $R
echo "./dialects/$D -> $H" >> $R
echo "	except ( ./dialects/$D/NEW );" >> $R
echo "	except ( ./dialects/$D/OLD ./dialects/$D/RCS );" >> $R
echo "	install src/lsof4/dialects/$D ;" >> $R

# Do the actual distribution.

(cd $HOME/src/lsof4; rdist $SHP -f $R)
rm $R
echo done
